<cfcomponent extends="base">

	<!--- ********************************************************************************************* --->
    <!--- ********************************* DATABASE SELECTS ****************************************** --->

    
    <!--- funcQryGetElderPriority --->
    <cffunction name="funcQryGetElderPriority" returntype="any">
        <cfargument default="-1" name="ElderID" required="no" />

        <cfquery datasource="eldersprogram" name="qryGetElderPriority">
            SELECT e.PriorityID, p.PriorityName
            FROM ElderList as e INNER JOIN Priority as p on e.PriorityID = p.PriorityID
            WHERE e.ElderListID = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
        </cfquery>
        <cfreturn qryGetElderPriority />
    </cffunction>
    <!--- funcQryGetElderPriority --->
    

	<!--- SELECT All Acuity Levels --->
    <cffunction name="funcQryAllAcuityLevels" returntype="any">
    	<cfargument default="-1" name="PriorityID" required="no" />
    	
    	<cfif ARGUMENTS.PriorityID EQ 'All'>
          <cfset ARGUMENTS.PriorityID = -1 />
        </cfif>
        <cfquery datasource="eldersprogram" name="qryAllAcuityLevels">
			SELECT [PriorityID], [PriorityName], [Description]
            FROM [Priority]
            <cfif ARGUMENTS.PriorityID neq -1>WHERE [PriorityID] = <cfqueryparam value="#ARGUMENTS.PriorityID#" cfsqltype="cf_sql_integer" />
            <cfelseif ARGUMENTS.PriorityID EQ -1>
                Where 1=1
            <cfelse>
                WHERE 1=2
            </cfif>
            ORDER BY [PriorityID]
        </cfquery>
    	<cfreturn qryAllAcuityLevels />
    </cffunction>
    <!--- SELECT All Acuity Levels --->



    <!--- SELECT Informal Support --->
    <cffunction name="funcQrySelectInformalSupport" returntype="any">
    	<cfargument default="-1" name="ElderListID" required="yes" />
        <cfquery datasource="eldersprogram" name="qrySelectInformalSupport">
			SELECT *
            FROM [InformalSupport]
            WHERE [ElderListID] = <cfqueryparam value="#ARGUMENTS.ElderListID#" cfsqltype="cf_sql_integer" />
            ORDER BY [InformalSupportID]
        </cfquery>
    	<cfreturn qrySelectInformalSupport />
    </cffunction>
    <!--- SELECT Informal Support --->



    <!--- SELECT Transaction Codes --->
    <cffunction name="funcQryAllTransactionCodes" returntype="any">
        <cfquery datasource="eldersprogram" name="qryAllTransactionCodes">
			SELECT [TransactionCodeID], [TransactionCode], [Description]
            FROM [TransactionCodes]
            ORDER BY [TransactionCode]
        </cfquery>
    	<cfreturn qryAllTransactionCodes />
    </cffunction>
    <!--- SELECT Transaction Codes --->



    <!--- SELECT Transaction Code --->
    <cffunction name="funcQryGetTransactionCode" returntype="any">
    	<cfargument default="-1" name="Desc" required="yes" />
        <cfquery datasource="eldersprogram" name="qryGetTransactionCode">
			SELECT [TransactionCodeID], [TransactionCode], [Description]
            FROM [TransactionCodes]
            WHERE [Description] = <cfqueryparam value="#ARGUMENTS.Desc#" cfsqltype="cf_sql_varchar" />
        </cfquery>
    	<cfreturn qryAllTransactionCode />
    </cffunction>
    <!--- SELECT Transaction Code --->



    <!--- SELECT Prior Auths by Elder--->
    <cffunction name="funcQrySelectPriorAuthsByElder" returntype="any">
    	<cfargument default="-1" name="ElderID" required="yes" />
        <cfquery datasource="eldersprogram" name="qrySelectPriorAuthsByElder">
			SELECT [PriorAuthID],[ElderID],[PriorAuthDate],[AuthNum],[ServiceAuthorized],
            [AuthUnits],[FromDate],[ThruDate],[RemUnits],[PALocked]
            FROM [PriorAuthorizations]
            WHERE [ElderID] = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
            ORDER BY [PriorAuthDate]
        </cfquery>
    	<cfreturn qrySelectPriorAuthsByElder />
    </cffunction>
    <!--- SELECT All Acuity Levels --->



    <!--- SELECT Prior Auths by ID--->
    <cffunction name="funcQrySelectPriorAuthsByID" returntype="any">
        <cfargument default="-1" name="PriorAuthID" required="yes" />
        <cfquery datasource="eldersprogram" name="qrySelectPriorAuthsByElder">
			SELECT [PriorAuthID],[ElderID],[PriorAuthDate],[AuthNum],[ServiceAuthorized],
            [AuthUnits],[FromDate],[ThruDate],[RemUnits],[PALocked]
            FROM [PriorAuthorizations]
            WHERE [PriorAuthID] = <cfqueryparam value="#ARGUMENTS.PriorAuthID#" cfsqltype="cf_sql_integer" />
            ORDER BY [PriorAuthDate]
        </cfquery>
    	<cfreturn qrySelectPriorAuthsByElder />
    </cffunction>
    <!--- SELECT All Acuity Levels --->



	<!--- SELECT Providers --->
    <cffunction name="funcQryActiveProviders" returntype="any">
    	<cfargument default="" name="OrderBy" required="no" />
        <cfquery datasource="eldersprogram" name="qryActiveProviders">
			SELECT [ProviderLastName], [ProviderFirstName], [ProviderID]
            FROM [Provider]
            WHERE [ProviderActive] = 1 OR [ProviderDeleted] <> 1
            ORDER BY
            	<cfif ARGUMENTS.OrderBy NEQ "">
                	#ARGUMENTS.OrderBy#
                <cfelse>
                	[ProviderLastName]
                </cfif>
        </cfquery>
    	<cfreturn qryActiveProviders />
    </cffunction>
    <!--- SELECT Providers --->



    <!--- SELECT Provider--->
    <cffunction name="funcQryProvider" returntype="any">
    	<cfargument default="" name="ID" required="no" />
        <cfquery datasource="eldersprogram" name="qryActiveProvider">
			SELECT [ProviderLastName], [ProviderFirstName], [ProviderID]
            FROM [Provider]
            WHERE ProviderID = <cfqueryparam value="#ARGUMENTS.ID#" cfsqltype="cf_sql_integer" />

        </cfquery>

        <cfset retVal = qryActiveProvider.ProviderFirstName & " " & qryActiveProvider.ProviderLastName />
    	<cfreturn  retVal/>
    </cffunction>
    <!--- SELECT Provider --->



    <!--- SELECT Providers for supervisor signature--->
    <cffunction name="funcQryProvidersForSignature" returntype="any">
        <cfquery datasource="eldersprogram" name="qryProvidersForSignature">
			SELECT [ProviderLastName], [ProviderFirstName], [ProviderID]
            FROM [Provider]
            WHERE [ProviderID] <> <cfqueryparam value="58" cfsqltype="cf_sql_integer" />
            AND [ProviderID] <> <cfqueryparam value="57" cfsqltype="cf_sql_integer" />
            ORDER BY [ProviderLastName]
        </cfquery>
    	<cfreturn qryProvidersForSignature />
    </cffunction>
    <!--- SELECT Providers for supervisor signature--->



    <!--- SELECT Providers --->
    <cffunction name="funcQryProvidersByID" returntype="any">
    	<cfargument default="-1" name="ProviderID" required="yes" />
        <cfquery datasource="eldersprogram" name="qryProvidersByID">
			SELECT ProviderID, ProviderName, ProviderActive, ProviderFirstName,
             ProviderLastName, ProviderDeleted, RosettaID 
            FROM [Provider]
            WHERE [ProviderID] = <cfqueryparam value="#ARGUMENTS.ProviderID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    	<cfreturn qryProvidersByID />
    </cffunction>
    <!--- SELECT Providers --->


    <!--- SELECT All Providers --->
    <cffunction name="funcQryAllProviders" returntype="any">
        <cfquery datasource="eldersprogram" name="qryAllProviders">
			SELECT [ProviderLastName], [ProviderFirstName], [ProviderId], [ProviderActive]
            FROM [Provider]
            <!---WHERE [ProviderDeleted] <> 1--->
            ORDER BY [ProviderLastName]
        </cfquery>
    	<cfreturn qryAllProviders />
    </cffunction>
    <!--- SELECT All Providers --->



    <!--- SELECT Elders without contacts --->
    <cffunction name="funcQryAllEldersNoContacts" returntype="any">
        <cfquery datasource="eldersprogram" name="qryAllEldersNoContacts">
			SELECT [LastName], [FirstName], [ElderListId]
            FROM [ElderList]
            ORDER BY [LastName]
        </cfquery>
    	<cfreturn qryAllEldersNoContacts />
    </cffunction>
    <!--- SELECT Elders without contacts--->


    <!--- SELECT Elder --->
    <cffunction name="funcQryGetElderById" returntype="any">
    	<cfargument name="elder_id" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryGetElderById">
			SELECT [LastName], [FirstName], [ElderListId], CONVERT( VARCHAR(10), [DOB], 101) as [MM/DD/YYYY]
            FROM [ElderList]
            WHERE [ElderListId] = <cfqueryparam value="#ARGUMENTS.elder_id#" cfsqltype="cf_sql_integer" />
        </cfquery>
    	<cfreturn qryGetElderById />
    </cffunction>
    <!--- SELECT Elder--->



    <!--- SELECT all guests --->
    <cffunction name="funcQryAllGuests" returntype="any">
        <cfquery datasource="eldersprogram" name="qryAllGuests">
			SELECT [GuestName], [GuestMealsID]
            FROM [GuestMeals]
            ORDER BY [GuestName]
        </cfquery>
    	<cfreturn qryAllGuests />
    </cffunction>
    <!--- SELECT all guests--->


    <!--- SELECT all Elders Meals for today --->
    <cffunction name="funcQryGetEldersMeals" returntype="any">
        
        <cfquery datasource="eldersprogram" name="qryGetEldersMeals">
			SELECT [CongregateMeals].[MealID], [CongregateMeals].[ProviderID],
            	   [CongregateMeals].[MealDate], [CongregateMeals].[ElderID],
                   [CongregateMeals].[MealBilled],
                   [ElderList].[FirstName] + ', ' + [ElderList].[LastName] as [FullName]
            FROM [CongregateMeals] INNER JOIN
                 [ElderList] ON [CongregateMeals].[ElderID] = [ElderList].[ElderListId]
            WHERE [MealDate] = <cfqueryparam value="#dateFormat(Now(), 'mm/dd/yyyy')#" cfsqltype="cf_sql_date" />
            ORDER BY [ElderList].[LastName]
        </cfquery>
        
    	<cfreturn qryGetEldersMeals />
    </cffunction>
    <!--- SELECT all Elders Meals for today --->


    <!--- SELECT all guests Meals for today --->
    <cffunction name="funcQryGetGuestMeals" returntype="any">
        <cfquery datasource="eldersprogram" name="qryGetGuestMeals">
			SELECT [GuestMealsID], [MealDate], [GuestName]
            FROM [GuestMeals]
            WHERE [MealDate] = <cfqueryparam value="#dateFormat(Now(), 'mm/dd/yyyy')#" cfsqltype="cf_sql_date" />
            ORDER BY [GuestName]
        </cfquery>
    	<cfreturn qryGetGuestMeals />
    </cffunction>
    <!--- SELECT all guests Meals for today --->


    <!--- SELECT all Regional Corps --->
    <cffunction name="funcQryAllRegionalCorps" returntype="any">
        <cfquery datasource="eldersprogram" name="qryAllRegionalCorps">
			SELECT [RegionalCorpID], [RegionalCorp]
            FROM [RegionalCorp]
            ORDER BY [RegionalCorp]
        </cfquery>
    	<cfreturn qryAllRegionalCorps />
    </cffunction>
    <!--- SELECT all Regional Corps --->


    <!--- SELECT all Ethnicity's --->
    <cffunction name="funcQryAllEthnicity" returntype="any">
        <cfquery datasource="eldersprogram" name="qryAllEthnicity">
			SELECT [EthnicityID], [Ethnicity]
            FROM [Ethnicity]
            ORDER BY [Ethnicity]
        </cfquery>
    	<cfreturn qryAllEthnicity />
    </cffunction>
    <!--- SELECT all Ethnicity's --->



    <!--- SELECT get Intake by ID --->
    <cffunction name="funcQryGetIntakeByID" returntype="any">
    <cfargument name="ElderID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryGetIntakeByID">
			SELECT
            <!---A. Customer Information--->
            	[ElderListID],
                [LastName],
                [FirstName],
                [MiddleInitial],
                CONVERT( VARCHAR(10), [DOB], 101) as [DOB],
                CONVERT( VARCHAR(10), [DateOfContact], 101) as [DateOfContact],
                [Gender],
                [Address],
                [AptSpaceNo],
                [City],
                [State],
                [Zip],
                [HomePhone],
                [MailingAddress],
                [MailingAptSpaceNo],
                [MailingCity],
                [MailingState],
                [MailingZip],
                [SSN],
                [TTCM],
                [SignatureCaseNumber],
                [ProviderID],
                <!---A. Customer Information--->

                <!---B. Legal Representative--->
                [LegalRepName],
                [LegalRepHomePhone],
                [LegalRepCellPhone],
                [LegalRepRelationship],
                <!---B. Legal Representative--->

                <!---C. Emergency Contacts--->
                [EmergencyContactName],
                [EmergencyContactHomePhone],
                [EmergencyContactCellPhone],
                [EmergencyContactRelationship],
                [EmergencyContactName2],
                [EmergencyContactHomePhone2] ,
                [EmergencyContactCellPhone2],
                [EmergencyContactRelationship2],
                <!---C. Emergency Contacts--->

                <!---D. Current Employment Status--->
                [EmploymentStatus],
                <!---D. Current Employment Status--->

                <!---E. Primary Care Provider Information--->
                [ProviderName],
                [ProviderPhoneNumber],
                [ProviderClinic],
                <!---E. Primary Care Provider Information--->

                <!---F. ANCSA Regional Corporation--->
                [RegionalCorp],
                <!---F. ANCSA Regional Corporation--->

                <!---G. Ethnicity--->
                [Ethnicity],
                [EthnicityOther],
                [PrimaryLanguage],
                [SecondaryLanguage],
                <!---G. Ethnicity--->

                <!---H. Current Living Arrangements--->
                [RaisingGrandchildren],
                [Grandchildren],
                [GrandchildrenAges],
                [HousingType],
                [HousingTypeOther],
                [Pets],
                [PetsType],
                [HouseHoldSmoker],
                [HouseHoldSmokerInHome],
                [HouseHoldSmokerOutdoors],
                <!---H. Current Living Arrangements--->

                <!---I. Transportation--->
                [MeansOfTransport],
                [AltMeansOfTransport],
                [RequireTransport],
                <!---I. Transportation--->

                <!---J. Current Use of Assitive/Support Device--->
                [AssitiveDevice],
                [AssitiveDeviceOther],
                [NeedVehicleLift],
                <!---J. Current Use of Assitive/Support Device--->

                <!---K. Instrumental Activities of Daily Living (IADL)--->
                [AssistedLivingFacility],                
                [PreparingMeals],
                [PreparingMealsManage],
                [DoingHouseWork],
                [DoingHouseWorkManage],
                [DoingLaundry],
                [DoingLaundryManage],
                [DoingShopping],
                [DoingShoppingManage],
                <!---K. Instrumental Activities of Daily Living (IADL)--->

                <!---L. Informal Support / F.C.S.I--->
                <!---Another database SELECT is needed.  Database insert happens after this one.  qrySelectCareGiver--->
                [ServicesCannotProvide],
                
                <!---L. Informal Support / F.C.S.I--->

                <!---M. Formal Support Service--->
                [DayServiceAgency],
                [DayServiceAgencyFrequency],
                [PersonalCareAgency],
                [PersonalCareAgencyFrequency],
                [HomeDeliveredMealsAgency],
                [HomeDeliveredMealsAgencyFrequency],
                [HomeHealthAgency],
                [HomeHealthAgencyFrequency],
                [RespiteCareAgency],
                [RespiteCareAgencyFrequency],
                [TransportationAgency],
                [TransportationAgencyFrequency],
                [OtherAgency],
                [OtherAgencyFrequency],
                <!---M. Formal Support Service--->

                <!---N. Health Insurance--->
                [MedicarePartANo],
                [MedicarePartBNo],
                [MedicarePartDNo],
                [MedicaidNo],
                [PrivateInsuranceNo],
                [InsuranceComments],
                <!---N. Health Insurance--->

                <!---O. Signatures--->
                [Signer],
                CONVERT( VARCHAR(10), [ElderSignatureDate], 101) as [ElderSignatureDate],
                CONVERT( VARCHAR(10), [StaffSignatureDate], 101) as [StaffSignatureDate],
                CONVERT( VARCHAR(10), [SupervisorSignatureDate], 101) as [SupervisorSignatureDate],
                [ElderSignature],
                [StaffSignature],
                [SupervisorSignature],
                [PriorityID]
                <!---O. Signatures--->
            FROM [ElderList]
            WHERE [ElderListID] = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    	<cfreturn qryGetIntakeByID />
    </cffunction>
    <!--- SELECT get Intake by ID --->



    <!--- SELECT Elder Caregiver --->
    <cffunction name="funcQrySelectCaregivers" returntype="any">
    	<cfargument name="ElderListID" default="-1" required="yes" />

        <cfquery datasource="eldersprogram" name="qrySelectCaregivers">
			SELECT [ElderID], [LastName], [FirstName], [Address], [City], [State], [Zip], [Phone],
            	[CellPhone], [RelationshiptoElder], [EmploymentStatus], [HouseholdStatus], [NameUsuallyAssists],
                [UsuallyAssistsPhone], [CareGiverID], [Contact], [ContactFrequency], [ServiceCantProvide]
            FROM [Caregiver]
            WHERE ElderID = <cfqueryparam value="#ARGUMENTS.ElderListID#" cfsqltype="cf_sql_integer" />
            ORDER BY [CareGiverID]
        </cfquery>

    	<cfreturn qrySelectCaregivers />
    </cffunction>
    <!--- SELECT Elder Caregiver --->



    <!--- SELECT Elder Caregiver --->
    <cffunction name="funcQrySelectCaregiver" returntype="any">
    	<cfargument name="CareGiverID" default="-1" required="yes" />

        <cfquery datasource="eldersprogram" name="qrySelectCaregiver">
			SELECT [ElderID], [LastName], [FirstName], [Address], [City], [State], [Zip], [Phone],
            	[CellPhone], [RelationshiptoElder], [EmploymentStatus], [HouseholdStatus], [NameUsuallyAssists],
                [UsuallyAssistsPhone], [CareGiverID], [Contact], [ContactFrequency], [ServiceCantProvide]
            FROM [Caregiver]
            WHERE CareGiverID = <cfqueryparam value="#ARGUMENTS.CareGiverID#" cfsqltype="cf_sql_integer" />
            ORDER BY [CareGiverID]
        </cfquery>
    	<cfreturn qrySelectCaregiver />
    </cffunction>
    <!--- SELECT Elder Caregiver --->




    <!--- SELECT Service Plan --->
    <cffunction name="funcQrySelectServicePlans" returntype="any">
    	<cfargument name="ElderID" default="-1" required="no" type="numeric" />
        <cfargument name="PlanID" default="-1" required="no" type="numeric"/>

        <cfquery datasource="eldersprogram" name="qrySelectServicePlans">
			SELECT
            	[PlanID],
                [ElderID],
                <!--- [PriorityID], --->
                [CareCoordinator],
                [CareAttendant],
                [ProviderID],
                [MealPreparation],
                [MealPreparationOther],
                [LightChore],
                [LightChoreOther],
                [HomeVisit],
                [HomeVisitOther],
                [GroupVisit],
                [GroupVisitOther],
                [Telephoning],
                [TelephoningOther],
                <!--- [PreparingMeals],
                [PreparingMealsManage],
                [DoingHouseWork],
                [DoingHouseWorkManage],
                [DoingLaundry],
                [DoingLaundryManage],
                [DoingShopping],
                [DoingShoppingManage], --->
                [ElderSignature],
                [ElderSignatureDate],
                [StaffSignature],
                [StaffSignatureDate],
                [SupervisorSignature],
                [SupervisorSignatureDate],
                [Active],
                CONVERT( VARCHAR(10), [PlanDate], 101) as [PlanDate],
                CONVERT( VARCHAR(10), [EvalDate], 101) as [EvalDate]<!--- ,
                [IADLTotal] --->
			FROM [ServicePlans]
            WHERE [ElderID] = #ARGUMENTS.ElderID#
            <cfif  ARGUMENTS.PlanID neq -1>
            	AND [PlanID] = #ARGUMENTS.PlanID#
            </cfif>
            ORDER BY [PlanDate]


        </cfquery>
        <cfreturn  qrySelectServicePlans/>
    </cffunction>
	<!--- SELECT Service Plan --->



    <!--- SELECT Service Plan --->
    <cffunction name="funcQrySelectServicePlanByID" returntype="any">
        <cfargument name="PlanID" default="-1" required="yes" />

        <cfquery datasource="eldersprogram" name="qrySelectServicePlanByID">
			SELECT
            	[PlanID],
                [ElderID],
                <!--- [PriorityID], --->
                [CareCoordinator],
                [CareAttendant],
                [ProviderID],
                [MealPreparation],
                [MealPreparationOther],
                [LightChore],
                [LightChoreOther],
                [HomeVisit],
                [HomeVisitOther],
                [GroupVisit],
                [GroupVisitOther],
                [Telephoning],
                [TelephoningOther],
                <!--- [PreparingMeals],
                [PreparingMealsManage],
                [DoingHouseWork],
                [DoingHouseWorkManage],
                [DoingLaundry],
                [DoingLaundryManage],
                [DoingShopping],
                [DoingShoppingManage], --->
                [Comments],
                [ElderSignature],
                [ElderSignatureDate],
                [StaffSignature],
                [StaffSignatureDate],
                [SupervisorSignature],
                [SupervisorSignatureDate],
                [Active],
                CONVERT( VARCHAR(10), [PlanDate], 101) as [PlanDate],
                CONVERT( VARCHAR(10), [EvalDate], 101) as [EvalDate]<!--- ,
                [IADLTotal] --->
			FROM [ServicePlans]
            WHERE [PlanID] = <cfqueryparam value="#ARGUMENTS.PlanID#" cfsqltype="cf_sql_integer" />
        </cfquery>
        <cfreturn  qrySelectServicePlanByID/>
    </cffunction>
	<!--- SELECT Service Plan --->



    <!--- SELECT Daily Progress Notes by Elder --->
    <cffunction name="funcQrySelectDailyProgressNotesByElder" returntype="any">
        <cfargument name="ElderID" default="-1" required="no" />
        <cfargument name="DailyProgressNoteID" default="-1" required="no" />

        <cfquery datasource="eldersprogram" name="qrySelectDailyProgressNotesByElder">
			SELECT
                [DailyProgressNoteID],
                [ElderID],
                [ProviderID],
                [PANumber],
                [NoteDate],
                [Medicare],
                [Medicaid],
                [ThirdParty],
                [Chore],
                [ChoreTimeIn],
                [ChoreTimeOut],
                [UnbilledChoreUnits],
                [DayOfCare],
                [DayOfCareTimeIn],
                [DayOfCareTimeOut],
                [UnbilledDayOfCareUnits],
                [MedicalTransportation],
                [MedicalTransportationTrips],
                [AddressFirstPickup],
                [TimeFirstPickup],
                [AddressFirstDropOff],
                [TimeFirstDropOff],
                [AddressSecondPickup],
                [TimeSecondPickup],
                [AddressSecondDropOff],
                [TimeSecondDropOff],
                [UnbilledMedicalTransportationUnits],
                [InHomeVisit],
                [InHomeVisitTimeIn],
                [InHomeVisitTimeOut],
                [GroupVisit],
                [GroupVisitTimeIn],
                [GroupVisitTimeOut],
                [OffSiteVisit],
                [OffSiteVisitTimeIn],
                [OffSiteVisitTimeOut],
                [FamilySupport],
                [InformationFCSI],
                [AssistanceFCSI],
                [LightMealPrep],
                [Escort],
                [FoodAssistance],
                [FoodBox],
                [HealthPromotions],
                [Information],
                [InPatientVisit],
                [Interpretation],
                [MedRefillAssistance],
                [ReferralService],
                [Telephoning],
                [TelephoningCount],
                [WritingReading],
                [TTCM],
                [TTCMType],
                [TTCMTimeIn],
                [TTCMTimeOut],
                [UnbilledTTCMUnits],
                [ActivitiesOuting],
                [Banking],
                [MedicationPickUp],
                [OtherTransport],
                [Potluck],
                [Shopping],
                [DNKATransportation],
                [DNKAHomeVisit],
                [DNKAGroupVisit],
                [DNKATelephoning],
                [DNKAChore],
                [DNKAMealPrep],
                [CancelledTransportation],
                [CancelledHomeVisit],
                [CancelledGroupVisit],
                [CancelledTelephoning],
                [CancelledChore],
                [CancelledMealPrep],
                [StaffSignature],
                CONVERT( VARCHAR(10), [StaffSignatureDate], 101) as [StaffSignatureDate],
                [Comments],
                [Referral],
                [FollowUp],
                [ScheduledAppointments],
                [Other]
			FROM [DailyProgressNotes]
            WHERE 1=1
            <cfif ARGUMENTS.ElderID NEQ -1>
            	AND [ElderID] = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
            <cfelseif ARGUMENTS.DailyProgressNoteID NEQ -1>
            	AND [DailyProgressNoteID] = <cfqueryparam value="#ARGUMENTS.DailyProgressNoteID#" cfsqltype="cf_sql_integer" />
            <cfelse>
            	AND [ElderID] = -1
            </cfif>
            ORDER BY [NoteDate] DESC
        </cfquery>
        <cfreturn  qrySelectDailyProgressNotesByElder/>
    </cffunction>
	<!--- SELECT Daily Progress Notes by Elder --->




    <!--- ********************************* DATABASE SELECTS ****************************************** --->
    <!--- ********************************************************************************************* --->




    <!--- ********************************************************************************************* --->
    <!--- ********************************* DATABASE INSERTS ****************************************** --->



    <!--- INSERT Elder Caregiver --->
    <cffunction name="funcQryInsertCareGiver" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
            <cfquery datasource="eldersprogram" name="qryInsertElderCaregiver">
            	INSERT INTO [Caregiver] ([ElderID])
                VALUES (<cfqueryparam value="#ARGUMENTS.FORM.ElderID#" cfsqltype="cf_sql_integer" /> )

                 SELECT @@Identity AS ID
            </cfquery>

            <cfset FORM.CareGiverID = qryInsertElderCaregiver.ID />
            <cfset funcQryUpdateElderCaregiver(FORM) />
            <cfreturn qryInsertElderCaregiver.ID />
    </cffunction>
	<!--- INSERT Elder Caregiver --->



    <!--- INSERT Prior Auth for elder --->
    <cffunction name="funcQryInsertPriorAuth" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
            <cfquery datasource="eldersprogram" name="qryInsertPriorAuth">
            	INSERT INTO [PriorAuthorizations] ([ElderID])
                VALUES (<cfqueryparam value="#ARGUMENTS.FORM.ElderID#" cfsqltype="cf_sql_integer" /> )

                 SELECT @@Identity AS ID
            </cfquery>

            <cfset FORM.PriorAuthID = qryInsertPriorAuth.ID />
            <cfset funcQryUpdatePriorAuth(FORM) />
    </cffunction>
	<!--- INSERT Prior Auth for elder --->


    <!--- INSERT Elder Meals --->
    <cffunction name="funcQryInsertElderMeals" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfargument name="MealBilled" default="-1" required="no" />

        <cfquery datasource="eldersprogram" name="qryInsertElderMeals">
			INSERT INTO [CongregateMeals]
            ([ProviderID], [MealDate], [ElderID]<!--- , [MealBilled] --->)
            VALUES
            (<cfqueryparam value="#ARGUMENTS.FORM.providerID#" cfsqltype="cf_sql_integer" />,
             <cfqueryparam value="#ARGUMENTS.FORM.MealDate#" cfsqltype="cf_sql_date" />,
             <cfqueryparam value="#ARGUMENTS.FORM.ElderID#" cfsqltype="cf_sql_integer" /><!--- ,
             <cfqueryparam value="#ARGUMENTS.FORM.MealBilled#" cfsqltype="cf_sql_bit" /> --->
            )
        </cfquery>
    </cffunction>
	<!--- INSERT Elder Meals --->


    <!--- INSERT Guest Meals --->
    <cffunction name="funcQryInsertGuestMeals" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <!--- ElderID is guest name in this case --->

        <cfquery datasource="eldersprogram" name="qryInsertGuestMeals">
			INSERT INTO [GuestMeals]
            ([MealDate], [GuestName], [ProviderID])
            VALUES
            (<cfqueryparam value="#ARGUMENTS.FORM.MealDate#" cfsqltype="cf_sql_date" />,
             <cfqueryparam value="#ARGUMENTS.FORM.ElderID#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.ProviderID#" cfsqltype="cf_sql_integer" />
            )
        </cfquery>
    </cffunction>
	<!--- INSERT Guest Meals --->


    <!--- INSERT Service Plan --->
    <cffunction name="funcQryInsertServicePlan" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryInsertServicePlan">
			INSERT INTO [ServicePlans]
            ([ElderID])
            VALUES
            (<cfqueryparam value="#ARGUMENTS.FORM.ElderID#" cfsqltype="cf_sql_integer" />)

            SELECT @@Identity AS ID
        </cfquery>

        <cfset ARGUMENTS.FORM.PlanID = qryInsertServicePlan.ID/>

        <cfset funcQryUpdateServicePlan(ARGUMENTS.FORM) />

        <cfreturn ARGUMENTS.FORM.ElderID/>
    </cffunction>
	<!--- INSERT Service Plan --->


    <!--- INSERT Provider --->
    <cffunction name="funcQryInsertProvider" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryInsertProvider">
			INSERT INTO [Provider]
            ([ProviderFirstName], [ProviderLastName], [ProviderActive], [ProviderDeleted], [ProviderName] )
            VALUES
            (
             <cfqueryparam value="#ARGUMENTS.FORM.firstName#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.lastName#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.active#" cfsqltype="cf_sql_bit" />,
             0,
             <cfqueryparam value="#ARGUMENTS.FORM.firstName#, #ARGUMENTS.FORM.lastName#" cfsqltype="cf_sql_varchar" />
            )
        </cfquery>
    </cffunction>
	<!--- INSERT Provider --->


    <!--- INSERT Intake --->
    <cffunction name="funcQryInsertIntake" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryInsertElder">
        	INSERT INTO [ElderList] ([LastName])
            VALUES(<cfqueryparam value="#ARGUMENTS.FORM.LastName#" cfsqltype="cf_sql_varchar" />)

            SELECT @@Identity AS ID
        </cfquery>

        <cfset funcQryInsertInformalSupport(qryInsertElder.ID, ARGUMENTS.FORM) />
        <cfset funcQryUpdateIntake(qryInsertElder.ID, ARGUMENTS.FORM) />

        <cfquery datasource="eldersprogram" name="qryUpdateCaregivers">
        	UPDATE [Caregiver]
            SET
            [ElderID] = <cfqueryparam value="#qryInsertElder.ID#" cfsqltype="cf_sql_integer" />
            WHERE ElderID = -1
        </cfquery>

        <cfreturn  qryInsertElder.ID/>
    </cffunction>
	<!--- INSERT Intake --->


    <!--- INSERT Progressnote --->
    <cffunction name="funcQryInsertInformalSupport" returntype="any">
    	<cfargument name="ElderListID" default="-1" required="yes" />
    	<cfargument name="FORM" default="-1" required="yes" />
	       <cfquery datasource="eldersprogram" name="qryInsertInformalSupport">
			INSERT INTO [InformalSupport]
             	([ElderListID], [NameUsuallyAssists1], [UsuallyAssistsPhone1], [NameUsuallyAssists2], [UsuallyAssistsPhone2],
                 [NameUsuallyAssists3], [UsuallyAssistsPhone3], [NameUsuallyAssists4], [UsuallyAssistsPhone4])
            VALUES
            (<cfqueryparam value="#ARGUMENTS.ElderListID#" cfsqltype="cf_sql_integer" />,
             <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists1#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone1#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists2#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone2#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists3#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone3#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists4#" cfsqltype="cf_sql_varchar" />,
             <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone4#" cfsqltype="cf_sql_varchar" />
             )
        </cfquery>
    </cffunction>
	<!--- INSERT Progressnote --->


    <!--- INSERT Progressnote --->
    <cffunction name="funcQryInsertProgressNote" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
	       <cfquery datasource="eldersprogram" name="qryInsertProgressNote">
			INSERT INTO [DailyProgressNotes]
             	(
                	[ElderID], [NoteDate]
                )
            VALUES
            (
            	<cfqueryparam value="#ARGUMENTS.FORM.ElderID#" cfsqltype="cf_sql_integer" />,
                <cfqueryparam value="#ARGUMENTS.FORM.NoteDate#" cfsqltype="cf_sql_date" />
            )
            SELECT @@Identity AS ID

        </cfquery>
        <cfset funcQryUpdateProgressNoteByID(qryInsertProgressNote.ID, ARGUMENTS.FORM) />
        <cfreturn ARGUMENTS.FORM.ElderID />
    </cffunction>
	<!--- INSERT Progressnote --->



    <!--- ********************************* DATABASE INSERTS ****************************************** --->
    <!--- ********************************************************************************************* --->



    <!--- ********************************************************************************************* --->
    <!--- ********************************* DATABASE UPDATES ****************************************** --->



    <!--- UPDATE ProgressNote  --->
    <cffunction name="funcQryUpdateProgressNoteByID" returntype="any">
    	<cfargument name="DailyProgressNoteID" default="-1" required="Yes" />
    	<cfargument name="FORM" default="-1" required="yes" />

        <cfset UTILITIES = CreateObject("component", "utilities") />

        <cfquery datasource="eldersprogram" name="qryUpdateProgressNoteByID">
			UPDATE [DailyProgressNotes]
            SET
                [ElderID] = <cfqueryparam value="#UTILITIES.funcBooleanTest(ARGUMENTS.FORM.ElderID)#" cfsqltype="cf_sql_integer" />,
                [ProviderID] = <cfqueryparam value="#ARGUMENTS.FORM.StaffSignature#"
					cfsqltype="cf_sql_integer" />,
                [PANumber] = <cfqueryparam value="#ARGUMENTS.FORM.PANumber#" cfsqltype="cf_sql_varchar" />,
                [Medicare] =
                <cfif isDefined("ARGUMENTS.FORM.Medicare")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [Medicaid] =
                <cfif isDefined("ARGUMENTS.FORM.Medicaid")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [ThirdParty] =
                <cfif isDefined("ARGUMENTS.FORM.ThirdParty")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [Chore] =
                <cfif isDefined("ARGUMENTS.FORM.Chore")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [ChoreTimeIn] = <cfif ARGUMENTS.FORM.ChoreTimeIn eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.ChoreTimeIn#" cfsqltype="cf_sql_time" />,
                </cfif>
                [ChoreTimeOut] = <cfif ARGUMENTS.FORM.ChoreTimeOut eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.ChoreTimeOut#" cfsqltype="cf_sql_time" />,
                </cfif>
                [UnbilledChoreUnits] = <cfqueryparam value="#val(ARGUMENTS.FORM.UnbilledChoreUnits)#" cfsqltype="cf_sql_integer" />,
                [DayOfCare] =
				<cfif isDefined("ARGUMENTS.FORM.DayOfCare")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [DayOfCareTimeIn] = <cfif ARGUMENTS.FORM.DayOfCareTimeIn eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.DayOfCareTimeIn#" cfsqltype="cf_sql_time" />,
                </cfif>

                [DayOfCareTimeOut] = <cfif ARGUMENTS.FORM.DayOfCareTimeOut eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.DayOfCareTimeOut#" cfsqltype="cf_sql_time" />,
                </cfif>
                [UnbilledDayOfCareUnits] = <cfqueryparam value="#val(ARGUMENTS.FORM.UnbilledDayOfCareUnits)#" cfsqltype="cf_sql_integer" />,
                [MedicalTransportation] = <cfif isDefined("ARGUMENTS.FORM.MedicalTransportation")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [MedicalTransportationTrips] = <cfqueryparam value="#val(ARGUMENTS.FORM.MedicalTransportationTrips)#"
                	cfsqltype="cf_sql_integer" />,
                [AddressFirstPickup] = <cfqueryparam value="#Trim(ARGUMENTS.FORM.AddressFirstPickup)#" cfsqltype="cf_sql_varchar" />,
                [TimeFirstPickup] = <cfif ARGUMENTS.FORM.TimeFirstPickup eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.TimeFirstPickup#" cfsqltype="cf_sql_time" />,
                </cfif>
                [AddressFirstDropOff] =<cfqueryparam value="#Trim(ARGUMENTS.FORM.AddressFirstDropOff)#" cfsqltype="cf_sql_varchar" />,
                [TimeFirstDropOff] = <cfif ARGUMENTS.FORM.TimeFirstDropOff eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.TimeFirstDropOff#" cfsqltype="cf_sql_time" />,
                </cfif>
                [AddressSecondPickup] =<cfqueryparam value="#Trim(ARGUMENTS.FORM.AddressSecondPickup)#" cfsqltype="cf_sql_varchar" />,
                [TimeSecondPickup] = <cfif ARGUMENTS.FORM.TimeSecondPickup eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.TimeSecondPickup#" cfsqltype="cf_sql_time" />,
                </cfif>
                [AddressSecondDropOff] = <cfqueryparam value="#Trim(ARGUMENTS.FORM.AddressSecondDropOff)#"
                cfsqltype="cf_sql_varchar" />,
                [TimeSecondDropOff] = <cfif ARGUMENTS.FORM.TimeSecondDropOff eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.TimeSecondDropOff#" cfsqltype="cf_sql_time" />,
                </cfif>
                [UnbilledMedicalTransportationUnits] = <cfqueryparam
                	value="#val(ARGUMENTS.FORM.UnbilledMedicalTransportationUnits)#" cfsqltype="cf_sql_integer" />,
                [InHomeVisit] =
                <cfif isDefined("ARGUMENTS.FORM.InHomeVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [InHomeVisitTimeIn] = <cfif ARGUMENTS.FORM.InHomeVisitTimeIn eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.InHomeVisitTimeIn#" cfsqltype="cf_sql_time" />,
                </cfif>
                [InHomeVisitTimeOut] = <cfif ARGUMENTS.FORM.InHomeVisitTimeOut eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.InHomeVisitTimeOut#" cfsqltype="cf_sql_time" />,
                </cfif>

                [GroupVisit] =
                <cfif isDefined("ARGUMENTS.FORM.GroupVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [GroupVisitTimeIn] = <cfif ARGUMENTS.FORM.GroupVisitTimeIn eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.GroupVisitTimeIn#" cfsqltype="cf_sql_time" />,
                </cfif>
                [GroupVisitTimeOut] = <cfif ARGUMENTS.FORM.GroupVisitTimeOut eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.GroupVisitTimeOut#" cfsqltype="cf_sql_time" />,
                </cfif>

                [OffSiteVisit] =
                <cfif isDefined("ARGUMENTS.FORM.OffSiteVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [OffSiteVisitTimeIn] = <cfif ARGUMENTS.FORM.OffSiteVisitTimeIn eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.OffSiteVisitTimeIn#" cfsqltype="cf_sql_time" />,
                </cfif>
                [OffSiteVisitTimeOut] = <cfif ARGUMENTS.FORM.OffSiteVisitTimeOut eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.OffSiteVisitTimeOut#" cfsqltype="cf_sql_time" />,
                </cfif>

                [FamilySupport] =
                <cfif isDefined("ARGUMENTS.FORM.FamilySupport")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [InformationFCSI] =
                <cfif isDefined("ARGUMENTS.FORM.InformationFCSI")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [AssistanceFCSI] =
                <cfif isDefined("ARGUMENTS.FORM.AssistanceFCSI")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [LightMealPrep] =
                <cfif isDefined("ARGUMENTS.FORM.LightMealPrep")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [Escort] =
                <cfif isDefined("ARGUMENTS.FORM.Escort")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [FoodAssistance] =
                <cfif isDefined("ARGUMENTS.FORM.FoodAssistance")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [FoodBox] =
                <cfif isDefined("ARGUMENTS.FORM.FoodBox")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [HealthPromotions] =
                <cfif isDefined("ARGUMENTS.FORM.HealthPromotions")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [Information] =
                <cfif isDefined("ARGUMENTS.FORM.Information")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [InPatientVisit] =
                <cfif isDefined("ARGUMENTS.FORM.InPatientVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [Interpretation] =
                <cfif isDefined("ARGUMENTS.FORM.Interpretation")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [MedRefillAssistance] =
                <cfif isDefined("ARGUMENTS.FORM.MedRefillAssistance")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [ReferralService] =
                <cfif isDefined("ARGUMENTS.FORM.ReferralService")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>

                [Telephoning] =
                <cfif isDefined("ARGUMENTS.FORM.Telephoning")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [TelephoningCount] = <cfqueryparam value="#val(ARGUMENTS.FORM.TelephoningCount)#" cfsqltype="cf_sql_integer" />,
                [WritingReading] =
                <cfif isDefined("ARGUMENTS.FORM.WritingReading")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [TTCM] =
                <cfif isDefined("ARGUMENTS.FORM.TTCM")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [TTCMTimeIn] = <cfif ARGUMENTS.FORM.TTCMTimeIn eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.TTCMTimeIn#" cfsqltype="cf_sql_time" />,
                </cfif>
                [TTCMTimeOut] = <cfif ARGUMENTS.FORM.TTCMTimeOut eq "">
                	NULL,
                <cfelse>
                	<cfqueryparam value="#ARGUMENTS.FORM.TTCMTimeOut#" cfsqltype="cf_sql_time" />,
                </cfif>
                [TTCMType] = <cfqueryparam value="#ARGUMENTS.FORM.TTCMType#" cfsqltype="cf_sql_varchar" />,
                [UnbilledTTCMUnits] = <cfqueryparam value="#val(ARGUMENTS.FORM.UnbilledTTCMUnits)#" cfsqltype="cf_sql_integer" />,
                [ActivitiesOuting] = <cfqueryparam value="#UTILITIES.funcBooleanTest(ARGUMENTS.FORM.ActivitiesOuting)#"
                	cfsqltype="cf_sql_integer" />,
                [Banking] = <cfqueryparam value="#UTILITIES.funcBooleanTest(ARGUMENTS.FORM.Banking)#" cfsqltype="cf_sql_integer" />,
                [MedicationPickUp] = <cfqueryparam value="#UTILITIES.funcBooleanTest(ARGUMENTS.FORM.MedicationPickUp)#"
                	cfsqltype="cf_sql_integer" />,
                [OtherTransport] = <cfqueryparam value="#UTILITIES.funcBooleanTest(ARGUMENTS.FORM.OtherTransport)#"
                	cfsqltype="cf_sql_integer" />,
                [Potluck] = <cfqueryparam value="#UTILITIES.funcBooleanTest(ARGUMENTS.FORM.Potluck)#" cfsqltype="cf_sql_integer" />,
                [Shopping] = <cfqueryparam value="#UTILITIES.funcBooleanTest(ARGUMENTS.FORM.Shopping)#" cfsqltype="cf_sql_integer" />,

                [DNKATransportation] =
                <cfif isDefined("ARGUMENTS.FORM.DNKATransportation")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [DNKAHomeVisit] =
                <cfif isDefined("ARGUMENTS.FORM.DNKAHomeVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [DNKAGroupVisit] =
                <cfif isDefined("ARGUMENTS.FORM.DNKAGroupVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [DNKATelephoning] =
                <cfif isDefined("ARGUMENTS.FORM.DNKATelephoning")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [DNKAChore] =
                <cfif isDefined("ARGUMENTS.FORM.DNKAChore")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [DNKAMealPrep] =
                <cfif isDefined("ARGUMENTS.FORM.DNKAMealPrep")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [CancelledTransportation] =
                <cfif isDefined("ARGUMENTS.FORM.CancelledTransportation")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [CancelledHomeVisit] =
                <cfif isDefined("ARGUMENTS.FORM.CancelledHomeVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [CancelledGroupVisit] =
                <cfif isDefined("ARGUMENTS.FORM.CancelledGroupVisit")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [CancelledMealPrep] =
                <cfif isDefined("ARGUMENTS.FORM.CancelledMealPrep")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [CancelledTelephoning] =
                <cfif isDefined("ARGUMENTS.FORM.CancelledTelephoning")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [CancelledChore] =
                <cfif isDefined("ARGUMENTS.FORM.CancelledChore")>
                	<cfqueryparam value="1" cfsqltype="cf_sql_bit" />,
                <cfelse>
                 	<cfqueryparam value="0" cfsqltype="cf_sql_bit" />,
                </cfif>
                [Comments] = <cfqueryparam value="#Trim(ARGUMENTS.FORM.Comments)#" cfsqltype="cf_sql_varchar" />,
                [Referral] = <cfqueryparam value="#Trim(ARGUMENTS.FORM.Referral)#" cfsqltype="cf_sql_varchar" />,
                [FollowUp] = <cfqueryparam value="#Trim(ARGUMENTS.FORM.FollowUp)#" cfsqltype="cf_sql_varchar" />,
                [ScheduledAppointments] = <cfqueryparam value="#Trim(ARGUMENTS.FORM.ScheduledAppointments)#"
                	cfsqltype="cf_sql_varchar" />,
                <cfif ARGUMENTS.FORM.StaffSignatureDate neq 'null' >
                	[StaffSignatureDate] = <cfqueryparam value="#ARGUMENTS.FORM.StaffSignatureDate#"
                    cfsqltype="cf_sql_date" />,
               		[StaffSignature] = <cfqueryparam value="#ARGUMENTS.FORM.StaffSignature#" cfsqltype="cf_sql_varchar" />,
                </cfif>
                [Other] = <cfqueryparam value="#Trim(ARGUMENTS.FORM.Other)#" cfsqltype="cf_sql_varchar" />
            WHERE [DailyProgressNoteID] = <cfqueryparam value="#ARGUMENTS.DailyProgressNoteID#" cfsqltype="cf_sql_integer" />
        </cfquery>

    </cffunction>
	<!--- UPDATE ProgressNote  --->



    <!--- UPDATE Informal Support --->
    <cffunction name="funcQryUpdateInformalSupport" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
    	<cfif ARGUMENTS.FORM.InformalSupportID neq "">
	       <cfquery datasource="eldersprogram" name="qryUpdateInformalSupport">
			UPDATE [InformalSupport]
            SET
            [NameUsuallyAssists1] = <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists1#" cfsqltype="cf_sql_varchar" />,
            [UsuallyAssistsPhone1] = <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone1#" cfsqltype="cf_sql_varchar" />,
            [NameUsuallyAssists2] = <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists2#" cfsqltype="cf_sql_varchar" />,
            [UsuallyAssistsPhone2] = <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone2#" cfsqltype="cf_sql_varchar" />,
            [NameUsuallyAssists3] = <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists3#" cfsqltype="cf_sql_varchar" />,
            [UsuallyAssistsPhone3] = <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone3#" cfsqltype="cf_sql_varchar" />,
            [NameUsuallyAssists4] = <cfqueryparam value="#ARGUMENTS.FORM.NameUsuallyAssists4#" cfsqltype="cf_sql_varchar" />,
            [UsuallyAssistsPhone4] = <cfqueryparam value="#ARGUMENTS.FORM.UsuallyAssistsPhone4#" cfsqltype="cf_sql_varchar" />
            WHERE [ElderListID] = <cfqueryparam value="#ARGUMENTS.FORM.ElderID#" cfsqltype="cf_sql_integer" />
        </cfquery>
        </cfif>
    </cffunction>
	<!--- UPDATE Informal Support --->



    <!--- UPDATE Intake  --->
    <cffunction name="funcQryUpdateIntake" returntype="any">
    	<cfargument name="ElderID" default="-1" required="yes" />
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryUpdateElder">
			UPDATE [ElderList]
            SET
				<!---A. Customer Information--->
                [LastName] = <cfqueryparam value="#ARGUMENTS.FORM.LastName#" cfsqltype="cf_sql_varchar" />,
                [FirstName] = <cfqueryparam value="#ARGUMENTS.FORM.FirstName#" cfsqltype="cf_sql_varchar" />,
                [MiddleInitial] = <cfqueryparam value="#ARGUMENTS.FORM.MiddleInitial#" cfsqltype="cf_sql_varchar" />,
                [DOB] = <cfqueryparam value="#ARGUMENTS.FORM.DOB#" cfsqltype="cf_sql_date" /> ,
                [DateOfContact] = <cfqueryparam value="#ARGUMENTS.FORM.DateOfContact#" cfsqltype="cf_sql_date" />,
                [Gender] = <cfqueryparam value="#ARGUMENTS.FORM.Gender#" cfsqltype="cf_sql_varchar" />,
                [Address] = <cfqueryparam value="#ARGUMENTS.FORM.Address#" cfsqltype="cf_sql_varchar" />,
                [AptSpaceNo] = <cfqueryparam value="#ARGUMENTS.FORM.AptSpaceNo#" cfsqltype="cf_sql_varchar" />,
                [City] = <cfqueryparam value="#ARGUMENTS.FORM.City#" cfsqltype="cf_sql_varchar" />,
                [State] = <cfqueryparam value="#ARGUMENTS.FORM.State#" cfsqltype="cf_sql_varchar" />,
                [Zip] = <cfqueryparam value="#ARGUMENTS.FORM.Zip#" cfsqltype="cf_sql_varchar" />,
                [HomePhone] = <cfqueryparam value="#ARGUMENTS.FORM.HomePhone#" cfsqltype="cf_sql_varchar" />,
                [MailingAddress] = <cfqueryparam value="#ARGUMENTS.FORM.MailingAddress#" cfsqltype="cf_sql_varchar" />,
                [MailingAptSpaceNo] = <cfqueryparam value="#ARGUMENTS.FORM.MailingAptSpaceNo#" cfsqltype="cf_sql_varchar" />,
                [MailingCity] = <cfqueryparam value="#ARGUMENTS.FORM.MailingCity#" cfsqltype="cf_sql_varchar" />,
                [MailingState] = <cfqueryparam value="#ARGUMENTS.FORM.MailingState#" cfsqltype="cf_sql_varchar" />,
                [MailingZip] = <cfqueryparam value="#ARGUMENTS.FORM.MailingZip#" cfsqltype="cf_sql_varchar" />,
                [SSN] = <cfqueryparam value="#ARGUMENTS.FORM.SSN#" cfsqltype="cf_sql_varchar" />,
                [TTCM] = <cfqueryparam value="#ARGUMENTS.FORM.TTCM#" cfsqltype="cf_sql_integer" />,
				[SignatureCaseNumber] = <cfqueryparam value="#ARGUMENTS.FORM.SignatureCaseNumber#" cfsqltype="cf_sql_varchar" />,
                [ProviderID] = <cfqueryparam value="#ARGUMENTS.FORM.ProviderID#" cfsqltype="cf_sql_integer" />,
                [PriorityID] = <cfqueryparam value="#ARGUMENTS.FORM.PriorityID#" cfsqltype="cf_sql_integer" />,
                <!---A. Customer Information--->

                <!---B. Legal Representative--->
                [LegalRepName] = <cfqueryparam value="#ARGUMENTS.FORM.LegalRepName#" cfsqltype="cf_sql_varchar" />,
                [LegalRepHomePhone] = <cfqueryparam value="#ARGUMENTS.FORM.LegalRepHomePhone#" cfsqltype="cf_sql_varchar" />,
                [LegalRepCellPhone] = <cfqueryparam value="#ARGUMENTS.FORM.LegalRepCellPhone#" cfsqltype="cf_sql_varchar" />,
                [LegalRepRelationship] = <cfqueryparam value="#ARGUMENTS.FORM.LegalRepRelationship#" cfsqltype="cf_sql_varchar" />,
                <!---B. Legal Representative--->

                <!---C. Emergency Contacts--->
                [EmergencyContactName] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactName#" cfsqltype="cf_sql_varchar" />,
                [EmergencyContactHomePhone] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactHomePhone#" 	cfsqltype="cf_sql_varchar" />,
                [EmergencyContactCellPhone] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactCellPhone#" cfsqltype="cf_sql_varchar" />,
                [EmergencyContactRelationship] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactRelationship#" cfsqltype="cf_sql_varchar" />,
                [EmergencyContactName2] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactName2#" cfsqltype="cf_sql_varchar" />,
                [EmergencyContactHomePhone2] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactHomePhone2#" cfsqltype="cf_sql_varchar" />,
                [EmergencyContactCellPhone2] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactCellPhone2#" cfsqltype="cf_sql_varchar" />,
                [EmergencyContactRelationship2] = <cfqueryparam value="#ARGUMENTS.FORM.EmergencyContactRelationship2#" cfsqltype="cf_sql_varchar" />,
                <!---C. Emergency Contacts--->

                <!---D. Current Employment Status--->
                [EmploymentStatus] = <cfqueryparam value="#ARGUMENTS.FORM.EmploymentStatus#" cfsqltype="cf_sql_varchar" />,
                <!---D. Current Employment Status--->

                <!---E. Primary Care Provider Information--->
                [ProviderName] = <cfqueryparam value="#ARGUMENTS.FORM.ProviderName#" cfsqltype="cf_sql_varchar" />,
                [ProviderPhoneNumber] = <cfqueryparam value="#ARGUMENTS.FORM.ProviderPhoneNumber#" cfsqltype="cf_sql_varchar" />,
                [ProviderClinic] = <cfqueryparam value="#ARGUMENTS.FORM.ProviderClinic#" cfsqltype="cf_sql_varchar" />,
                <!---E. Primary Care Provider Information--->

                <!---F. ANCSA Regional Corporation--->
                [RegionalCorp] = <cfqueryparam value="#ARGUMENTS.FORM.RegionalCorp#" cfsqltype="cf_sql_integer" />,
                <!---F. ANCSA Regional Corporation--->

                <!---G. Ethnicity--->
                [Ethnicity] = <cfqueryparam value="#ARGUMENTS.FORM.Ethnicity#" cfsqltype="cf_sql_integer" />,
                [EthnicityOther] = <cfqueryparam value="#ARGUMENTS.FORM.EthnicityOther#" cfsqltype="cf_sql_varchar" />,
                [PrimaryLanguage] = <cfqueryparam value="#ARGUMENTS.FORM.PrimaryLanguage#" cfsqltype="cf_sql_varchar" />,
                [SecondaryLanguage] = <cfqueryparam value="#ARGUMENTS.FORM.SecondaryLanguage#" cfsqltype="cf_sql_varchar" />,
                <!---G. Ethnicity--->

                <!---H. Current Living Arrangements--->
                [RaisingGrandchildren] = <cfqueryparam value="#ARGUMENTS.FORM.RaisingGrandchildren#" cfsqltype="cf_sql_varchar" />,
                [Grandchildren] = <cfqueryparam value="#ARGUMENTS.FORM.Grandchildren#" cfsqltype="cf_sql_varchar" />,
                [GrandchildrenAges] = <cfqueryparam value="#ARGUMENTS.FORM.GrandchildrenAges#" cfsqltype="cf_sql_varchar" />,
                [HousingType] = <cfqueryparam value="#ARGUMENTS.FORM.HousingType#" cfsqltype="cf_sql_varchar" />,
                [HousingTypeOther] = <cfqueryparam value="#ARGUMENTS.FORM.HousingTypeOther#" cfsqltype="cf_sql_varchar" />,
                [Pets] = <cfqueryparam value="#ARGUMENTS.FORM.Pets#" cfsqltype="cf_sql_integer" />,
                [PetsType] = <cfqueryparam value="#ARGUMENTS.FORM.PetsType#" cfsqltype="cf_sql_varchar" />,
                [HouseHoldSmoker] = <cfqueryparam value="#ARGUMENTS.FORM.HouseHoldSmoker#" cfsqltype="cf_sql_integer" />,
                [HouseHoldSmokerInHome] = <cfqueryparam value="#ARGUMENTS.FORM.HouseHoldSmokerInHome#" cfsqltype="cf_sql_integer" />,
                [HouseHoldSmokerOutdoors] = <cfqueryparam value="#ARGUMENTS.FORM.HouseHoldSmokerOutdoors#" cfsqltype="cf_sql_integer" />,
                <!---H. Current Living Arrangements--->

                <!---I. Transportation--->
                [MeansOfTransport] = <cfqueryparam value="#ARGUMENTS.FORM.MeansOfTransport#" cfsqltype="cf_sql_varchar" />,
                [AltMeansOfTransport] = <cfqueryparam value="#ARGUMENTS.FORM.AltMeansOfTransport#" cfsqltype="cf_sql_varchar" />,
                [RequireTransport] = <cfqueryparam value="#ARGUMENTS.FORM.RequireTransport#" cfsqltype="cf_sql_integer" />,
                <!---I. Transportation--->

                <!---J. Current Use of Assitive/Support Device--->
                [AssitiveDevice] = <cfqueryparam value="#ARGUMENTS.FORM.AssitiveDevice#" cfsqltype="cf_sql_varchar" />,
                [AssitiveDeviceOther] = <cfqueryparam value="#ARGUMENTS.FORM.AssitiveDeviceOther#" cfsqltype="cf_sql_varchar" />,
                [NeedVehicleLift] = <cfqueryparam value="#ARGUMENTS.FORM.NeedVehicleLift#" cfsqltype="cf_sql_integer" />,
                <!---J. Current Use of Assitive/Support Device--->

                <!---K. Instrumental Activities of Daily Living (IADL)--->
                [AssistedLivingFacility] =<cfqueryparam value="#ARGUMENTS.FORM.AssistedLivingFacility#" cfsqltype="cf_sql_integer" />,
                [PreparingMeals] = <cfqueryparam value="#val(ARGUMENTS.FORM.PreparingMeals)#" cfsqltype="cf_sql_integer"  />,
                [PreparingMealsManage] = <cfqueryparam value="#ARGUMENTS.FORM.PreparingMealsManage#" cfsqltype="cf_sql_varchar" />,
                [DoingHouseWork] = <cfqueryparam value="#val(ARGUMENTS.FORM.DoingHouseWork)#" cfsqltype="cf_sql_integer"  />,
                [DoingHouseWorkManage] = <cfqueryparam value="#ARGUMENTS.FORM.DoingHouseWorkManage#" cfsqltype="cf_sql_varchar" />,
                [DoingLaundry] = <cfqueryparam value="#val(ARGUMENTS.FORM.DoingLaundry)#" cfsqltype="cf_sql_integer"  />,
                [DoingLaundryManage] = <cfqueryparam value="#ARGUMENTS.FORM.DoingLaundryManage#" cfsqltype="cf_sql_varchar" />,
                [DoingShopping] = <cfqueryparam value="#val(ARGUMENTS.FORM.DoingShopping)#" cfsqltype="cf_sql_integer" />,
                [DoingShoppingManage] = <cfqueryparam value="#ARGUMENTS.FORM.DoingShoppingManage#" cfsqltype="cf_sql_varchar" />,
                <!--- [IADLTotal] = <cfqueryparam value="#val(ARGUMENTS.FORM.IADLTotal)#" cfsqltype="cf_sql_integer"  />, --->
				<!---L. Informal Support / F.C.S.I--->
                [ServicesCannotProvide] = <cfqueryparam value="#ARGUMENTS.FORM.ServicesCannotProvide#" cfsqltype="cf_sql_varchar" />,
                
                <!---M. Formal Support Service--->
                [DayServiceAgency] = <cfqueryparam value="#ARGUMENTS.FORM.DayServiceAgency#" cfsqltype="cf_sql_varchar" />,
                [DayServiceAgencyFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.DayServiceAgencyFrequency#"
                    cfsqltype="cf_sql_varchar" />,
                [PersonalCareAgency] = <cfqueryparam value="#ARGUMENTS.FORM.PersonalCareAgency#" cfsqltype="cf_sql_varchar" />,
                [PersonalCareAgencyFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.PersonalCareAgencyFrequency#"
                    cfsqltype="cf_sql_varchar" />,
                [HomeDeliveredMealsAgency] = <cfqueryparam value="#ARGUMENTS.FORM.HomeDeliveredMealsAgency#"
                	cfsqltype="cf_sql_varchar" />,
                [HomeDeliveredMealsAgencyFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.HomeDeliveredMealsAgencyFrequency#"
                    cfsqltype="cf_sql_varchar" />,
                [HomeHealthAgency] = <cfqueryparam value="#ARGUMENTS.FORM.HomeHealthAgency#" cfsqltype="cf_sql_varchar" />,
                [HomeHealthAgencyFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.HomeHealthAgencyFrequency#"
                    cfsqltype="cf_sql_varchar" />,
                [RespiteCareAgency] = <cfqueryparam value="#ARGUMENTS.FORM.RespiteCareAgency#" cfsqltype="cf_sql_varchar" />,
                [RespiteCareAgencyFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.RespiteCareAgencyFrequency#"
                    cfsqltype="cf_sql_varchar" />,
                [TransportationAgency] = <cfqueryparam value="#ARGUMENTS.FORM.TransportationAgency#" cfsqltype="cf_sql_varchar" />,
                [TransportationAgencyFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.TransportationAgencyFrequency#"
                    cfsqltype="cf_sql_varchar" />,
                [OtherAgency] = <cfqueryparam value="#ARGUMENTS.FORM.OtherAgency#" cfsqltype="cf_sql_varchar" />,
                [OtherAgencyFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.OtherAgencyFrequency#"
                	cfsqltype="cf_sql_varchar" />,
                <!---M. Formal Support Service--->

                <!---N. Health Insurance--->
                [MedicarePartANo] = <cfqueryparam value="#ARGUMENTS.FORM.MedicarePartANo#" cfsqltype="cf_sql_varchar" />,
                [MedicarePartBNo] = <cfqueryparam value="#ARGUMENTS.FORM.MedicarePartBNo#" cfsqltype="cf_sql_varchar" />,
                [MedicarePartDNo] = <cfqueryparam value="#ARGUMENTS.FORM.MedicarePartDNo#" cfsqltype="cf_sql_varchar" />,
                [MedicaidNo] = <cfqueryparam value="#ARGUMENTS.FORM.MedicaidNo#" cfsqltype="cf_sql_varchar" />,
                [PrivateInsuranceNo] = <cfqueryparam value="#ARGUMENTS.FORM.PrivateInsuranceNo#" cfsqltype="cf_sql_varchar" />,
                [InsuranceComments] = <cfqueryparam value="#ARGUMENTS.FORM.InsuranceComments#" cfsqltype="cf_sql_varchar"/>,
                <!---N. Health Insurance--->

                <!---O. Signatures--->
                [Signer] = <cfqueryparam value='#CGI.AUTH_USER#' cfsqltype="cf_sql_varchar" />

                <!---O. Signatures--->
            WHERE ElderListID = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
        </cfquery>

    </cffunction>
    
    
    
    <cffunction name="funcQryUpdateElderListSignatures" returntype="any">
        <cfargument name="ElderID" default="-1" required="yes" />
        <cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryUpdateProviderID">
                UPDATE [ElderList]
                SET
                [LastName] = <cfqueryparam value="#ARGUMENTS.FORM.LastName#" cfsqltype="cf_sql_varchar" />,
                <Cfif ARGUMENTS.FORM.ElderSignature NEQ "" OR ARGUMENTS.FORM.ElderSignature NEQ "no">
                    [ElderSignatureDate] = <cfqueryparam value="#ARGUMENTS.FORM.ElderSignatureDate#" cfsqltype="cf_sql_date" />,
                    [ElderSignature] = <cfqueryparam value="#ARGUMENTS.FORM.ElderSignature#" cfsqltype="cf_sql_varchar" />,
                </cfif>
                <Cfif ARGUMENTS.FORM.StaffSignature NEQ "" OR ARGUMENTS.FORM.StaffSignature NEQ "no">
                    [StaffSignatureDate] = <cfqueryparam value="#ARGUMENTS.FORM.StaffSignatureDate#" cfsqltype="cf_sql_date" />,
                    [StaffSignature] = <cfqueryparam value="#ARGUMENTS.FORM.StaffSignature#" cfsqltype="cf_sql_varchar" />,
                </cfif>
                <Cfif ARGUMENTS.FORM.StaffSignature NEQ "" OR ARGUMENTS.FORM.StaffSignature NEQ "no">
                    [SupervisorSignatureDate] = <cfqueryparam value="#ARGUMENTS.FORM.SupervisorSignatureDate#" cfsqltype="cf_sql_date" />,
                    [SupervisorSignature] = <cfqueryparam value="#ARGUMENTS.FORM.SupervisorSignature#" cfsqltype="cf_sql_varchar" />,
                </cfif>
                [Signer] = <cfqueryparam value='#CGI.AUTH_USER#' cfsqltype="cf_sql_varchar" />
                WHERE [ElderListID] = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
            </cfquery>
    </cffunction>
    
    
    
    <cffunction name="funcQryUpdateServicePlanSignatures" returntype="any">
        <cfargument name="PlanID" default="-1" required="yes" />
        <cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryUpdateProviderID">
                UPDATE [ServicePlans]
                SET
                [CareAttendant] = <cfqueryparam value="#ARGUMENTS.FORM.CareAttendant#" cfsqltype="cf_sql_varchar" />,
                <Cfif ARGUMENTS.FORM.ElderSignature NEQ "" OR ARGUMENTS.FORM.ElderSignature NEQ "no">
                    [ElderSignatureDate] = <cfqueryparam value="#ARGUMENTS.FORM.ElderSignatureDate#" cfsqltype="cf_sql_date" />,
                    [ElderSignature] = <cfqueryparam value="#ARGUMENTS.FORM.ElderSignature#" cfsqltype="cf_sql_varchar" />,
                </cfif>
                <Cfif ARGUMENTS.FORM.StaffSignature NEQ "" OR ARGUMENTS.FORM.StaffSignature NEQ "no">
                    [StaffSignatureDate] = <cfqueryparam value="#ARGUMENTS.FORM.StaffSignatureDate#" cfsqltype="cf_sql_date" />,
                    [StaffSignature] = <cfqueryparam value="#ARGUMENTS.FORM.StaffSignature#" cfsqltype="cf_sql_varchar" />,
                </cfif>
                <Cfif ARGUMENTS.FORM.StaffSignature NEQ "" OR ARGUMENTS.FORM.StaffSignature NEQ "no">
                    [SupervisorSignatureDate] = <cfqueryparam value="#ARGUMENTS.FORM.SupervisorSignatureDate#" cfsqltype="cf_sql_date" />,
                    [SupervisorSignature] = <cfqueryparam value="#ARGUMENTS.FORM.SupervisorSignature#" cfsqltype="cf_sql_varchar" />,
                </cfif>
                [Comments] = <cfqueryparam value='#ARGUMENTS.FORM.Comments#' cfsqltype="cf_sql_varchar" />
                WHERE [PlanID] = <cfqueryparam value="#ARGUMENTS.PlanID#" cfsqltype="cf_sql_integer" />
            </cfquery>
    </cffunction>
    
    
    
    <cffunction name="funcQryUpdateProviderID" returntype="any">
        <cfargument name="ElderID" default="-1" required="yes" />
        <cfargument name="ProviderID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryUpdateProviderID">
                UPDATE [ElderList]
                SET
                    [ProviderID] = <cfqueryparam value="#ARGUMENTS.ProviderID#" cfsqltype="cf_sql_integer" />
                WHERE [ElderListID] = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
            </cfquery>
    </cffunction>
    
    
    <cffunction name="funcQryUpdatePriorityID" returntype="any">
        <cfargument name="ElderID" default="-1" required="yes" />
        <cfargument name="PriorityID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryUpdateProviderID">
                UPDATE [ElderList]
                SET
                    [PriorityID] = <cfqueryparam value="#ARGUMENTS.PriorityID#" cfsqltype="cf_sql_integer" />
                WHERE [ElderListID] = <cfqueryparam value="#ARGUMENTS.ElderID#" cfsqltype="cf_sql_integer" />
            </cfquery>
    </cffunction>
    
    
    
    <cffunction name="funcQryUpdateElderCaregiver" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
    	<cfquery datasource="eldersprogram" name="qryUpdateElderCaregiver">
                UPDATE [Caregiver]
                SET
                    [LastName] = <cfqueryparam value="#ARGUMENTS.FORM.cg_LastName#" cfsqltype="cf_sql_varchar" />,
                    [FirstName] = <cfqueryparam value="#ARGUMENTS.FORM.cg_FirstName#" cfsqltype="cf_sql_varchar" />,
                    [Address] = <cfqueryparam value="#ARGUMENTS.FORM.cg_Address#" cfsqltype="cf_sql_varchar" />,
                    [City] = <cfqueryparam value="#ARGUMENTS.FORM.cg_City#" cfsqltype="cf_sql_varchar" />,
                    [State] = <cfqueryparam value="#ARGUMENTS.FORM.cg_State#" cfsqltype="cf_sql_varchar" />,
                    [Zip] = <cfqueryparam value="#ARGUMENTS.FORM.cg_Zip#" cfsqltype="cf_sql_varchar" />,
                    [Phone] = <cfqueryparam value="#ARGUMENTS.FORM.cg_Phone#" cfsqltype="cf_sql_varchar" />,
                    [RelationshiptoElder] = <cfqueryparam value="#ARGUMENTS.FORM.cg_RelationshiptoElder#"
                        cfsqltype="cf_sql_varchar" />,
                    [EmploymentStatus] = <cfqueryparam value="#ARGUMENTS.FORM.cg_EmploymentStatus#"
                        cfsqltype="cf_sql_varchar" />,
                    [HouseholdStatus] = <cfqueryparam value="#ARGUMENTS.FORM.cg_HouseholdStatus#"
                        cfsqltype="cf_sql_varchar" />,
                    [Contact] = <cfqueryparam value="#ARGUMENTS.FORM.cg_Contact#" cfsqltype="cf_sql_varchar" />,
                    [ContactFrequency] = <cfqueryparam value="#ARGUMENTS.FORM.cg_ContactFrequency#" cfsqltype="cf_sql_varchar" />
                WHERE [CareGiverID] = <cfqueryparam value="#ARGUMENTS.FORM.CareGiverID#" cfsqltype="cf_sql_integer" />
            </cfquery>
    </cffunction>



    <!--- UPDATE Provider  --->
    <cffunction name="funcQryUpdateProvider" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfargument name="logical_delete" default="0" required="no" />

        <cfquery datasource="eldersprogram" name="qryUpdateProvider">
			UPDATE [Provider]
            SET
            [ProviderFirstName] = <cfqueryparam value="#ARGUMENTS.FORM.firstName#" cfsqltype="cf_sql_varchar" />,
            [ProviderLastName] = <cfqueryparam value="#ARGUMENTS.FORM.lastName#" cfsqltype="cf_sql_varchar" />,
            [ProviderActive] = <cfqueryparam value="#ARGUMENTS.FORM.active#" cfsqltype="cf_sql_varchar" />
            <cfif ARGUMENTS.logical_delete eq 0>
            ,
            [ProviderDeleted] = 0
            <cfelseif ARGUMENTS.logical_delete eq 1>
            ,
            [ProviderDeleted] = 1
            </cfif>
            WHERE ProviderID = <cfqueryparam value="#ARGUMENTS.FORM.id#" cfsqltype="cf_sql_integer" />
        </cfquery>

    </cffunction>
	<!--- UPDATE Provider  --->



    <!--- UPDATE Prior Auth  --->
    <cffunction name="funcQryUpdatePriorAuth" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryUpdatePriorAuth">
			UPDATE [PriorAuthorizations]
            SET
                [ElderID] = <cfqueryparam value="#val(ARGUMENTS.FORM.ElderID)#" cfsqltype="cf_sql_integer" />,
                [PriorAuthDate] = <cfqueryparam value="#ARGUMENTS.FORM.PriorAuthDate#" cfsqltype="cf_sql_date" />,
                [AuthNum] = <cfqueryparam value="#val(ARGUMENTS.FORM.AuthNum)#" cfsqltype="cf_sql_integer" />,
                [ServiceAuthorized] = <cfqueryparam value="#ARGUMENTS.FORM.ServiceAuthorized#" cfsqltype="cf_sql_varchar" />,
                [AuthUnits] = <cfqueryparam value="#val(ARGUMENTS.FORM.AuthUnits)#" cfsqltype="cf_sql_integer" />,
                [FromDate] = <cfqueryparam value="#ARGUMENTS.FORM.FromDate#" cfsqltype="cf_sql_date" />,
                [ThruDate] = <cfqueryparam value="#ARGUMENTS.FORM.ThruDate#" cfsqltype="cf_sql_date" />,
                [RemUnits] = <cfqueryparam value="#val(ARGUMENTS.FORM.RemUnits)#" cfsqltype="cf_sql_integer" />,
                [PALocked] = <cfqueryparam value="#ARGUMENTS.FORM.PALocked#" cfsqltype="cf_sql_bit" />
            WHERE [PriorAuthID] = <cfqueryparam value="#val(ARGUMENTS.FORM.PriorAuthID)#" cfsqltype="cf_sql_integer" />
        </cfquery>

    </cffunction>
	<!--- UPDATE Prior Auth  --->



    <!--- UPDATE Service Plan --->
    <cffunction name="funcQryUpdateServicePlan" returntype="any">
    	<cfargument name="FORM" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryUpdateServicePlan">
			UPDATE [ServicePlans]
            SET
                [ElderID] = <cfqueryparam value="#val(ARGUMENTS.FORM.ElderID)#" cfsqltype="cf_sql_integer"  />,
                <!--- [PriorityID] = <cfqueryparam value="#val(ARGUMENTS.FORM.PriorityID)#" cfsqltype="cf_sql_integer"  />, --->                
                [CareAttendant] = <cfqueryparam value="#ARGUMENTS.FORM.CareAttendant#" cfsqltype="cf_sql_varchar" />,
                [CareCoordinator] = <cfqueryparam value="#ARGUMENTS.FORM.CareCoordinator#" cfsqltype="cf_sql_varchar" />,
                [PlanDate] = <cfqueryparam value="#ARGUMENTS.FORM.PlanDate#" cfsqltype="cf_sql_date" />,
                [EvalDate] = <cfqueryparam value="#ARGUMENTS.FORM.EvalDate#" cfsqltype="cf_sql_date" />,
                [MealPreparation] = <cfqueryparam value="#val(ARGUMENTS.FORM.MealPreparation)#" cfsqltype="cf_sql_integer"  />,
                [MealPreparationOther] = <cfqueryparam value="#ARGUMENTS.FORM.MealPreparationOther#" cfsqltype="cf_sql_varchar" />,
                [LightChore] = <cfqueryparam value="#val(ARGUMENTS.FORM.LightChore)#" cfsqltype="cf_sql_integer"  />,
                [LightChoreOther] = <cfqueryparam value="#ARGUMENTS.FORM.LightChoreOther#" cfsqltype="cf_sql_varchar" />,
                [HomeVisit] = <cfqueryparam value="#val(ARGUMENTS.FORM.HomeVisit)#" cfsqltype="cf_sql_integer"  />,
                [HomeVisitOther] = <cfqueryparam value="#ARGUMENTS.FORM.HomeVisitOther#" cfsqltype="cf_sql_varchar" />,
                [GroupVisit] = <cfqueryparam value="#val(ARGUMENTS.FORM.GroupVisit)#" cfsqltype="cf_sql_integer"  />,
                [GroupVisitOther] = <cfqueryparam value="#ARGUMENTS.FORM.GroupVisitOther#" cfsqltype="cf_sql_varchar" />,
                [Telephoning] = <cfqueryparam value="#val(ARGUMENTS.FORM.Telephoning)#" cfsqltype="cf_sql_integer"  />,
                [TelephoningOther] = <cfqueryparam value="#ARGUMENTS.FORM.TelephoningOther#" cfsqltype="cf_sql_varchar" />,
                <!--- [PreparingMeals] = <cfqueryparam value="#val(ARGUMENTS.FORM.PreparingMeals)#" cfsqltype="cf_sql_integer"  />,
                [PreparingMealsManage] = <cfqueryparam value="#ARGUMENTS.FORM.PreparingMealsManage#" cfsqltype="cf_sql_varchar" />,
                [DoingHouseWork] = <cfqueryparam value="#val(ARGUMENTS.FORM.DoingHouseWork)#" cfsqltype="cf_sql_integer"  />,
                [DoingHouseWorkManage] = <cfqueryparam value="#ARGUMENTS.FORM.DoingHouseWorkManage#" cfsqltype="cf_sql_varchar" />,
                [DoingLaundry] = <cfqueryparam value="#val(ARGUMENTS.FORM.DoingLaundry)#" cfsqltype="cf_sql_integer"  />,
                [DoingLaundryManage] = <cfqueryparam value="#ARGUMENTS.FORM.DoingLaundryManage#" cfsqltype="cf_sql_varchar" />,
                [DoingShopping] = <cfqueryparam value="#val(ARGUMENTS.FORM.DoingShopping)#" cfsqltype="cf_sql_integer" />,
                [DoingShoppingManage] = <cfqueryparam value="#ARGUMENTS.FORM.DoingShoppingManage#" cfsqltype="cf_sql_varchar" />, --->
                [Comments] = <cfqueryparam value="#ARGUMENTS.FORM.Comments#" cfsqltype="cf_sql_varchar" />,
                [ProviderID] = <cfqueryparam value="#val(ARGUMENTS.FORM.ProviderID)#" cfsqltype="cf_sql_integer"  />
            WHERE [PlanID] =  <cfqueryparam value="#ARGUMENTS.FORM.PlanID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
	<!--- UPDATE Service Plan --->






    <!--- ********************************* DATABASE UPDATES ****************************************** --->
    <!--- ********************************************************************************************* --->



    <!--- ********************************************************************************************* --->
    <!--- ********************************* DATABASE DELETES ****************************************** --->


    <!--- DELETE Elders Meals for today --->
    <cffunction name="funcQryDeleteEldersMeals" returntype="any">
    	<cfargument name="MealID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeleteEldersMeals">
			DELETE
            FROM [CongregateMeals]
            WHERE [MealID] = <cfqueryparam value="#ARGUMENTS.MealID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
    <!--- DELETE Elders Meals for today --->



    <!--- DELETE Elders Prior Auth--->
    <cffunction name="funcQryDeletePriorAuth" returntype="any">
    	<cfargument name="PriorAuthID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeletePriorAuth">
			DELETE
            FROM [PriorAuthorizations]
            WHERE [PriorAuthID] = <cfqueryparam value="#ARGUMENTS.PriorAuthID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
    <!--- DELETE Elders Prior Auth--->



    <!--- DELETE guests Meals for today --->
    <cffunction name="funcQryDeleteGuestMeals" returntype="any">
    	<cfargument name="MealID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeleteGuestMeals">
			DELETE
            FROM [GuestMeals]
            WHERE [GuestMealsID] = <cfqueryparam value="#ARGUMENTS.MealID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
    <!--- DELETE guests Meals for today --->



    <!--- DELETE caregiver by id --->
    <cffunction name="funcQryDeleteCaregiver" returntype="any">
    	<cfargument name="CaregiverID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeleteGuestMeals">
			DELETE
            FROM [Caregiver]
            WHERE [CaregiverID] = <cfqueryparam value="#ARGUMENTS.CaregiverID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
    <!--- DELETE caregiver by id --->



    <!--- DELETE DailyProgressNote by id --->
    <cffunction name="funcQryDeleteProgressNote" returntype="any">
    	<cfargument name="DailyProgressNoteID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeleteProgressNote">
			DELETE
            FROM [DailyProgressNotes]
            WHERE [DailyProgressNoteID] = <cfqueryparam value="#ARGUMENTS.DailyProgressNoteID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
    <!--- DELETE DailyProgressNote by id --->



    <!--- DELETE ServicePlan by id --->
    <cffunction name="funcQryDeleteServicePlan" returntype="any">
    	<cfargument name="PlanID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeleteServicePlan">
			DELETE
            FROM [ServicePlans]
            WHERE [PlanID] = <cfqueryparam value="#ARGUMENTS.PlanID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
    <!--- DELETE ServicePlan by id --->



    <!--- DELETE ElderList by id --->
    <cffunction name="funcQryDeleteIntake" returntype="any">
    	<cfargument name="ElderListID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeleteIntake">
			DELETE
            FROM [ElderList]
            WHERE [ElderListID] = <cfqueryparam value="#ARGUMENTS.ElderListID#" cfsqltype="cf_sql_integer" />
        </cfquery>

        <cfquery datasource="eldersprogram" name="qryUpdateCaregivers">
        	DELETE
            FROM [Caregiver]
            WHERE ElderID = <cfqueryparam value="#ARGUMENTS.ElderListID#" cfsqltype="cf_sql_integer" />
        </cfquery>

    </cffunction>
    <!--- DELETE ElderList by id --->



    <!--- DELETE Provider by id --->
    <cffunction name="funcQryDeleteProvider" returntype="any">
    	<cfargument name="ProviderID" default="-1" required="yes" />
        <cfquery datasource="eldersprogram" name="qryDeleteServicePlan">
			DELETE
            FROM [Provider]
            WHERE [ProviderID] = <cfqueryparam value="#ARGUMENTS.ProviderID#" cfsqltype="cf_sql_integer" />
        </cfquery>
    </cffunction>
    <!--- DELETE Provider by id --->



    <!--- ********************************* DATABASE DELETES ****************************************** --->
    <!--- ********************************************************************************************* --->






</cfcomponent>